#include<iostream>
#include<cstring>
#include<string.h>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<list>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define maxn 100010
const double eps = 1e-8;
inline int read()
{
    int f = 1, res = 0; char ch = getchar();
    while( ch < '0' || ch > '9' )
    {
        if( ch == '-' ) f = -1;
        ch = getchar();
    }
    while( '0' <= ch && ch <= '9' )
    {
        res = ( res << 1 ) + ( res << 3 ) + ( ch - '0' );
        ch = getchar();
    }
    return res * f;
}
inline void write( int x )
{
    if( x < 0 ) putchar( '-' ), x = -x;
    if( x > 9 ) write( x / 10 );
    putchar( x % 10 + '0' );
}
int t, n, m, l, v, p[ maxn ];
int ll[ maxn ], rr[ maxn ];
bool f[ 1000010 ];
struct Car
{
    int d, v, a;
} car[ maxn ];
struct node
{
    int l, r;
} ans[ maxn ];
bool cmp1( node a, node b )
{
    return a.r - a.l < b.r - b.l;
    //if( a.l != b.l ) return a.l < b.l;
    //return a.r < b.r;
}
bool cmp2( node a, node b )
{
    if( a.l != b.l ) return a.l < b.l;
    return a.r < b.r;
}
bool cmp3( node a, node b )
{
    if( a.r != b.r ) return a.r > b.r;
    return a.l > b.l;
}
void solve()
{
    n = read(), m = read(), l = read(), v = read();
    memset( ll, 0, sizeof( ll ) );
    memset( rr, 0, sizeof( rr ) );
    memset( p, 0, sizeof( p ) );
    memset( car, 0, sizeof( car ) );
    memset( f, 0, sizeof( f ) );
    for( int i = 1; i <= n; i++ )
        car[ i ].d = read(), car[ i ].v = read(), car[ i ].a = read();
    for( int i = 1; i <= m; i++ )
        p[ i ] = read();
    for( int i = 1; i <= n; i++ )
    {
        //cout << i << endl;
        if( car[ i ].d > p[ m ] )
            continue;
        if( car[ i ].a < 0 )
        {
            int l = 1, r = m;
            while( l < r )
            {
                int mid = ( l + r ) >> 1;
                if( p[ mid ] < car[ i ].d )
                    l = mid + 1;
                else r = mid;
                //cout << l << "," << r << endl;
            }
            r = m;
            int s = p[ l ] - car[ i ].d;
            //cout << s << endl;
            //cout << ( 1.0 * sqrt( 1.0 * car[ i ].v * car[ i ].v + 2 * car[ i ].a * s ) - v ) << endl;
            if( 1.0 * car[ i ].v * car[ i ].v + 2 * car[ i ].a * s <= v * v )
                continue;
            //cout << "a";
            ll[ i ] = l;
            while( l < r )
            {
                int mid = ( l + r ) >> 1;
                s = p[ mid ] - car[ i ].d;
                if( 1.0 * car[ i ].v * car[ i ].v + 2 * car[ i ].a * s <= eps )
                {
                    r = mid - 1;
                    continue;
                }
                if( 1.0 * car[ i ].v * car[ i ].v + 2 * car[ i ].a * s <= v * v )
                    r = mid - 1;
                else l = mid + 1;
                //cout << sqrt( 1.0 * car[ i ].v * car[ i ].v + 2 * car[ i ].a * s ) << endl;
                //cout << l << "," << r << "," << 1.0 * sqrt( 1.0 * car[ i ].v * car[ i ].v + 2 * car[ i ].a * s ) << endl;
            }
            s = p[ l ] - car[ i ].d;
            //cout << ( 1.0 * sqrt( 1.0 * car[ i ].v * car[ i ].v + 2 * car[ i ].a * s ) ) << endl;
            if( 1.0 * car[ i ].v * car[ i ].v + 2 * car[ i ].a * s <= v * v )
                l--;

            rr[ i ] = l;
            //s = p[ 3 ] - car[ i ].d;
            //cout << 1.0 * sqrt( 1.0 * car[ i ].v * car[ i ].v + 2 * car[ i ].a * s ) << endl;
        }
        else if( car[ i ].a > 0 )
        {
            int l = 1, r = m;
            while( l < r )
            {
                int mid = ( l + r ) >> 1;
                int s = p[ mid ] - car[ i ].d;
                if( s < 0 )
                {
                    l = mid + 1;
                    continue;
                }
                if( car[ i ].v * car[ i ].v + 2 * car[ i ].a * s <= v * v )
                    l = mid + 1;
                else r = mid - 1;
                //cout << l << "," << r << endl;
            }
            int s = p[ l ] - car[ i ].d;
            ll[ i ] = l, rr[ i ] = m;
        }
        else
        {
            if( car[ i ].v > v )
            {
                int l = 1, r = m;
                while( l < r )
                {
                    int mid = ( l + r ) >> 1;
                    if( p[ mid ] < car[ i ].d )
                        l = mid + 1;
                    else r = mid;
                    //cout << l << "," << r << endl;
                }
                ll[ i ] = l;
                rr[ i ] = m;
            }
        }
    }
    int res = 0;
    for( int i = 1; i <= n; i++ )
    {
        if( ll[ i ] != 0 && rr[ i ] != 0 )
            res++, ans[ i ].l = ll[ i ], ans[ i ].r = rr[ i ];
        //cout << ll[ i ] << "," << rr[ i ] << endl;
    }
    write( res );
    putchar( ' ' );
    int cnt = 0, ans1 = 0;
    sort( ans + 1, ans + res + 1, cmp1 );

    for( int i = 1; i <= res; i++ )
    {
        bool p = 0;
        for( int j = ans[ i ].l; j <= ans[ i ].r; j++ )
            if( f[ j ] == 1 )
                p = 1;
        if( p == 0 )
            f[ ans[ i ].r ] = 1, cnt++;
    }
    ans1 = max( ans1, cnt ); cnt = 0;
    /*for( int i = 1; i <= m; i++ )
        cout << f[ i ];
    cout << endl << endl;*/
    for( int i = 1; i <= m; i++ )
        if( f[ i ] )
            cnt++;
    sort( ans + 1, ans + res + 1, cmp2 );
    /*for( int i = 1; i <= res; i++ )
        cout << ans[ i ].l << "," << ans[ i ].r << endl;*/
    for( int i = 1; i <= res; i++ )
    {
        bool p = 0;
        for( int j = ans[ i ].l; j <= ans[ i ].r; j++ )
            if( f[ j ] == 1 )
                p = 1;
        if( p == 0 )
            f[ ans[ i ].r ] = 1, cnt++;
    }
    cnt = 0;
    /*for( int i = 1; i <= m; i++ )
        cout << f[ i ];
    cout << endl << endl;*/
    for( int i = 1; i <= m; i++ )
        if( f[ i ] )
            cnt++;
    ans1 = max( ans1, cnt );
    sort( ans + 1, ans + res + 1, cmp3 );
    for( int i = res; i >= 1; i-- )
    {
        bool p = 0;
        for( int j = ans[ i ].l; j <= ans[ i ].r; j++ )
            if( f[ j ] == 1 )
                p = 1;
        if( p == 0 )
            f[ ans[ i ].l ] = 1, cnt++;
    }
    cnt = 0;
    /*for( int i = 1; i <= m; i++ )
        cout << f[ i ];
    cout << endl << endl;*/
    for( int i = 1; i <= m; i++ )
        if( f[ i ] )
            cnt++;
    ans1 = max( ans1, cnt );
    write( m - ans1 );
    puts( "" );
    return;
}
int main()
{
    freopen( "detect.in", "r", stdin );
    freopen( "detect.out", "w", stdout );
    t = read();
    while( t-- )
        solve();
    return 0;
}
